<template>
  <ea-input-number
    v-model.string="tempValueCom"
    v-bind="$attrs"
    :min="0"
    :max="100000000"
    :precision="3"
  />
</template>

<script>

import Vue from 'vue';
import EaInputNumber from '@/components/ea/EaInputNumber';
/**
 * 金额输入框
 */
export default {
  name: "ErpTableAmount",
  components: {
    EaInputNumber
  },
  model: {
    prop: "value",
    event: 'value-change'
  },
  props: {
    /**
     * 默认值
     * @public
     */
    value: {
      type: [String, Number],
      default: ''
    },
  },
  data () {
    return {
      tempValue: null
    };
  },
  computed: {
    tempValueCom: {
      get () {
        return this.value;
      },
      set (val) {
        this.handleChange(val);
      }
    }
  },
  watch: {
    value: {
      handler(value) {
        this.tempValue = value;
      },
      immediate: true
    },
  },
  methods: {
    /**
     * 通知父组件更新值
     * @param {string|number} data 值
     * @public
     */
    handleChange (data) {
      /**
       * 将值传递给父组件
       */
      this.$emit('value-change', data);
    }
  }
};
</script>

<style scoped>

</style>
